<include file="../header" />
<div class="wrapper">
    <div class="main">
        <div class="header text-center font-16">
            地址管理
            <div class="iconfont icon-zuo go_back"></div>
        </div>
        <div class="Address-content" id="user_address_list">
            <volist name="data" id="vo">
                <if condition="$vo['is_default'] eq 1">
                    <div class="flex address visited">
                <else/>
                    <div class="flex address">
                </if>
                        <div class="left iconfont icon-xuanzhong1 "></div>
                        <div class="center flex-1 address_choose" data-id="{BEESCRM:$vo.address_id}">
                            <div class="flex">
                                <div class="name">
                                    {BEESCRM:$vo.user_name}
                                </div>
                                <div>
                                    {BEESCRM:$vo.mobile}
                                </div>
                            </div>
                            <p>
                                {BEESCRM:$vo.address_detail}
                            </p>
                        </div>
                        <div class="right flex ">
                            <div class="iconfont icon-bianji" data-id="{BEESCRM:$vo.address_id}"></div>
                            <div class="iconfont icon-shanchu" data-id="{BEESCRM:$vo.address_id}"></div>
                        </div>
                    </div>
            </volist>
        </div>
    </div>
    <div id="bottom_div">&nbsp;</div>
    <a href="/Repaireast/RepaireastRepair/editAddress/type/{BEESCRM:$type}" class="btn add text-center">新增地址</a>
    <div class="pop-box hide">
        <input type="hidden" id="address_id">
        <div class="pop-hint">
            <div class="delete">
                <img src="/assets/repaireast/images/delete.png" alt="">
            </div>
            <div class="txt text-center">真的要删除？</div>
            <div class="text-center pop-btn flex">
                <a href="#" class="no">取消</a>
                <a href="#" class="yes btn-visit">确定</a>
            </div>
            <div class="iconfont icon-cheng1"></div>
        </div>
    </div>
</div>
<script src="/assets/repaireast/js/layer.js"></script>
<script src="/assets/repaireast/js/public.js"></script>
<script>
    $(function(){
        if( $("body").scrollTop()>0 ){
            $('#bottom_div').css('height','44px');
        }else{
            $('#bottom_div').css('height','0px');
        }
    });

    $('.icon-bianji').click(function () {
        var id = $(this).data('id');
        var type = "{BEESCRM:$type}";
        var url = '/Repaireast/RepaireastRepair/editAddress/address_id/'+id+'/type/'+type;
        window.location.href=url;
    });

    $('.icon-shanchu').click(function () {
        $('#address_id').val($(this).data('id'));
        $('.pop-box').removeClass('hide');
    });
    $('.icon-cheng1').click(function () {
        $('.pop-box').addClass('hide');
    });
    $('.pop-box .no').click(function () {
        $('.pop-box').addClass('hide');
    });
    $('.pop-box .yes').click(function () {
        $('.pop-box').addClass('hide');
        var address_id = $('#address_id').val();
        $.ajax({
            type:'post',
            url:"/Repaireast/RepaireastRepair/delUserAddress",
            dataType:'json',
            data:{
                'address_id' : address_id
            },
            success:function(data){
                fm.alert('操作成功!');
                setTimeout(function(){
                    location.reload();
                },2000);
            },
            error:function(){
                fm.alert('通讯失败，请稍后再试');
            }
        });
    });

    //点击地址跳回报修页
    $('#user_address_list .address_choose').click(function(){
        var id = $(this).data('id');
        var type = "{BEESCRM:$type}";
        if (type == 1) {
            var url = '/Repaireast/RepaireastRepair/dailyRepair/address_id/' + id;
        }else{
            var url = '/Repaireast/RepaireastRepair/fastRepair/address_id/' + id;
        }
        window.location.href=url;
    });
</script>
<include file="../footer" />